//
//  LoginViewController.m
//  happyHealthyWalk
//
//  Created by newhuidong on 16/2/20.
//  Copyright © 2016年 HuiDong. All rights reserved.
//

#import "LoginViewController.h"
#import "Header.h"
#import "UIBarButtonItem+Extensions.h"
#import "RegistViewController.h"
#import "TestViewController.h"
@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *PhoneTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UIImageView *phoneImage;
@property (weak, nonatomic) IBOutlet UIImageView *pswImage;
@property (weak, nonatomic) IBOutlet UIButton *eyeButton;
@property (weak, nonatomic) IBOutlet UILabel *mid_label;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title=@"登录";
    
    self.view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    self.navigationController.navigationBar.barTintColor=GreenColor;
    self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor whiteColor]};
    
    self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage=[UIImage new];
    self.navigationController.navigationBar.translucent=NO;
    
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(registButton)];
    
    
    [[UIBarButtonItem appearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

    self.loginBtn.layer.cornerRadius=5;
    
    [self setupUI];
    
}

-(void)setupUI{
    
    
    self.PhoneTF.keyboardType=UIKeyboardTypeNumberPad;
    
}
- (IBAction)seePassword:(id)sender {
    
    UIButton * button=sender;
    
    
    button.selected=!button.selected;
    
    
}
- (IBAction)Login:(id)sender {
    
    NSLog(@"登录");
    
    TestViewController * test=[[TestViewController alloc]init];
    
    [self presentViewController:test animated:YES completion:nil];
    
}
-(void)cancle{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
-(void)registButton{
    
    UIStoryboard * story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    RegistViewController * regist=[story instantiateViewControllerWithIdentifier:@"RegistViewController"];
    
    [self.navigationController pushViewController:regist animated:YES];
    
}

//键盘下落
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self.view endEditing:YES];
    
}

-(void)viewWillDisappear:(BOOL)animated{
    
    self.PhoneTF=nil;
    self.passwordTF=nil;
    self.loginBtn=nil;
    self.phoneImage=nil;
    self.pswImage=nil;
    self.mid_label=nil;
    
    
}
@end
